﻿using Newtonsoft.Json;
using System;
using System.Text.Json.Serialization;

namespace ThresholdAssistant.DataContract.Param
{
    /// <summary>
    /// 适配器接口请求参数
    /// </summary>
    [Serializable]
    public class AdapterContractParam
    {
        /// <summary>
        /// 操作结果
        /// </summary>
        [JsonProperty("success"), JsonPropertyName("success")]
        public bool Success { get; set; }

        /// <summary>
        /// 错误信息，成功将返回空
        /// </summary>
        [JsonProperty("message"), JsonPropertyName("message")]
        public string Message { get; set; }

        /// <summary>
        /// 服务器时间戳
        /// </summary>
        [JsonProperty("timestamp"), JsonPropertyName("timestamp")]
        public long Timestamp { get; set; }

        /// <summary>
        /// 业务流水号
        /// </summary>
        [JsonProperty("serial_no"), JsonPropertyName("serial_no")]
        public string SerialNo { get; set; } = Guid.NewGuid().ToString("N").ToUpper();

        /// <summary>
        /// 透传字段
        /// </summary>
        [JsonProperty("extend"), JsonPropertyName("extend")]
        public string Extend { get; set; }
    }

    /// <summary>
    /// 适配器接口请求参数
    /// </summary>
    [Serializable]
    public class AdapterContractParam<D> : AdapterContractParam
    {
        /// <summary>
        /// 封装层回调数据
        /// </summary>
        [JsonProperty("data"), JsonPropertyName("data")]
        public D Data { get; set; }
    }

    /// <summary>
    /// 适配器接口请求参数(只有dc的场景)
    /// </summary>
    [Serializable]
    public class AdapterContractDcParam<D> : AdapterContractParam
    {
        /// <summary>
        /// 微信透传上来的数据
        /// </summary>
        [JsonProperty("dc_data"), JsonPropertyName("dc_data")]
        public D DcData { get; set; }
    }

    /// <summary>
    /// 适配器接口请求参数
    /// </summary>
    [Serializable]
    public class AdapterContractParam<D, DC> : AdapterContractParam<D>
    {
        /// <summary>
        /// 微信透传上来的数据
        /// </summary>
        [JsonProperty("dc_data"), JsonPropertyName("dc_data")]
        public DC DcData { get; set; }
    }
}